<?php
  $template = new Template();
  $template->load("upload");
  if(FileServer::upload("../content/uploads/".$_POST['dir'],$_FILES['file'])){
    $name = $_FILES['file']['name'];
    $template->assign_var("MESSAGE",str_replace("{FILENAME}",$name,$language->getString("FILE_UPLOADED")));
    $path_info = pathinfo("../content/uploads/".$_POST['dir']."/".$name);
	if(strtolower($path_info['extension'] == 'jpg') or
	   strtolower($path_info['extension'] == 'jpeg') or
	   strtolower($path_info['extension'] == 'gif') or
	   strtolower($path_info['extension'] == 'png') or
	   strtolower($path_info['extension'] == 'bmp')){
       $template->show_if("SHOW_MEDIALIBARY",true);
       $template->assign_var("URL","/admin/index.php?page=addImage");
       $template->assign_var("FILE_PATH","/content/uploads/".$base."/".$name);
	}
  }
  else {
    $template->assign_var("MESSAGE",$language->getString("FILE_NOT_UPLOADED"));
  }
  $template->output();
?>